<?php

/*

Run from 1 Player Battle (battle_1p_run.php)

*/

$page_title = "Run from 1 Player Battle";
$rank_check = 1;
include "header.inc.php";

$findBattle = fetch("SELECT * FROM one_player_battles2 WHERE userid = '$userid' AND game = '$game'");
if (!$findBattle[id])
{
	die(header(error("battle_1player.php?game=$game","This fight does not exsist.")));
}

print $openHTML;

$findEnemy = fetch("SELECT * FROM one_players2 WHERE id = '$findBattle[enemy]' AND game = '$game'");
$findYourPet = fetch("SELECT * FROM user_pets2 WHERE id = '$findBattle[your_pet]' AND game = '$game'");
$findYourSpecies = fetch("SELECT * FROM pets2 WHERE id = '$findYourPet[species]' AND game = '$game'");

print "<p align=center><img src=images/user_images/opg_$game/enemies/enemy_$findEnemy[id].gif><br><font size=+2>The Winner!</font></p>";

print "<p>You run from $findEnemy[name], so by default $findEnemy[name] won the battle! Please try again soon!</p>";

mysql_query("UPDATE one_players2 SET wins=$findEnemy[wins]+1 WHERE id = '$findEnemy[id]' AND game = '$game'");
mysql_query("UPDATE user_pets2 SET one_p_loses=$findYourPet[one_p_loses]+1 WHERE id = '$findEnemy[id]' AND game = '$game'");

print "<p><a href=battle_center.php?game=$game>Back to the battle center!</a></p>";

mysql_query("DELETE FROM one_player_battles2 WHERE userid = '$userid' AND game = '$game'");

print $closeHTML;
?>